package com.company.gas.controller;


import com.company.gas.pojo.GasDeli;
import com.company.gas.service.IGasDeliService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.List;

@RestController
@Api(tags = "调度管理相关接口")
public class  GasDeliController {
    @Autowired
    private IGasDeliService iGasDeliService;

    //查询全部调度
    @GetMapping("/queryGasDeliList")
    @ApiOperation("查询全部调度")
    public List<GasDeli> queryGasDeliList(){
        List<GasDeli> gasDeliList= iGasDeliService.queryGasDeliList();
        for (GasDeli gasDeli : gasDeliList) {
            System.out.println(gasDeli);
        }
        return gasDeliList;
    }
    //查询单个调度
    @GetMapping("/queryGasDeliByID")
    @ApiOperation("根据deliId查询指定调度")
    public GasDeli queryGasDeliByID(@RequestParam(value = "调度ID") String deliId){
        GasDeli gasDeli = iGasDeliService.queryGasDeliByID(deliId);
        return gasDeli;
    }
    //添加调度
    @GetMapping("/addGasDeli")
    @ApiOperation("添加一个调度")
    public String addGasDeli(@RequestParam(value = "调度ID") String deliId,@RequestParam(value = "调度起点") String deliStart,
                             @RequestParam(value = "调度终点")String deliFinish,@RequestParam(value = "调度燃气量") BigDecimal deliAmount,
                             @RequestParam(value = "创建者") String createBy){
        int isaddGasDeli = iGasDeliService.addGasDeli(deliId, deliStart, deliFinish,deliAmount,createBy);
        if(isaddGasDeli == 1){
            return "add success";
        }else {
            return "failed";
        }
    }

}
